﻿/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * 
*     ___                              __                 _       __              __     __       *
*    /   |   _____ ____   ___   _____ /_/____   ____     | |     / /____   _____ / /____/ /_____  *
*   / /| |  / ___// __ \ / _ \ / ___// // __ \ / __ \    | | /| / // __ \ / ___// // __  // ___/  *
*  / ___ | _\_ \ / /_/ //  __// /   / // /_/ // / / /    | |/ |/ // /_/ // /   / // /_/ /_\_ \    *
* /_/  |_|/____// ____/ \___//_/   /_/ \____//_/ /_/     |__/|__/ \____//_/   /_/ \____//____/    *
*              /_/                                                                                *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Worlds.Application;

namespace Server.Framework
{
    /// <summary>
    /// Internal applicaiton framework logic.
    /// </summary>
    public static class Main
    {
        /// <summary>
        /// Application started hook, called when the applicaiton is started.
        /// </summary>
        public static EventHandlers.EventHandler ApplicationStarted;
        /// <summary>
        /// Application stopped hook, called when the applicaiton is stopped.
        /// </summary>
        public static EventHandlers.EventHandler ApplicationStopped;

        /// <summary>
        /// Application startup logic.
        /// </summary>
        public static void start()
        {
            /* First we need to initialize our plugins. */
            // TODO -> Plugins.

            /* Initialize the main applicaiton's form. */
            // TODO -> Main Form.

            /* Load the engine's configuration. */
            Configuration.load();
            Configuration.bind();

            /* Initialize the game database. */
            // TODO -> Game Database.

            /* Attempt to fire the plugin hook. */
            if (ApplicationStarted != null)
                ApplicationStarted();

            /* Initialize the networking engine. */
            // TODO -> Networking.

            /* Finally start the application loop. */
            // TODO -> Application Loop.
        }

        /// <summary>
        /// Application shutdown logic.
        /// </summary>
        public static void stop()
        {
            /* Destroy the networking engine. */
            // TODO -> Networking.

            /* Attempt to fire the plugin hook. */
            if (ApplicationStopped != null)
                ApplicationStopped();

            /* Destroy the game database. */
            // TODO -> Game Database.

            /* Save the engine's configuration. */
            Configuration.save();

            /* Destroy the main applicaiton's form. */
            // TODO -> Main Form.
        }
    }
}
